package org.jivesoftware.smackx.packet;

import java.util.Date;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.PacketExtension;

public class StreamInitiation extends IQ
{
  private Feature featureNegotiation;
  private File file;
  private String id;
  private String mimeType;

  public String getChildElementXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    if (getType().equals(IQ.Type.SET))
    {
      localStringBuilder.append("<si xmlns=\"http://jabber.org/protocol/si\" ");
      if (getSessionID() != null)
        localStringBuilder.append("id=\"").append(getSessionID()).append("\" ");
      if (getMimeType() != null)
        localStringBuilder.append("mime-type=\"").append(getMimeType()).append("\" ");
      localStringBuilder.append("profile=\"http://jabber.org/protocol/si/profile/file-transfer\">");
      String str = this.file.toXML();
      if (str != null)
        localStringBuilder.append(str);
    }
    while (true)
    {
      if (this.featureNegotiation != null)
        localStringBuilder.append(this.featureNegotiation.toXML());
      localStringBuilder.append("</si>");
      return localStringBuilder.toString();
      if (!(getType().equals(IQ.Type.RESULT)))
        break;
      localStringBuilder.append("<si xmlns=\"http://jabber.org/protocol/si\">");
    }
    throw new IllegalArgumentException("IQ Type not understood");
  }

  public DataForm getFeatureNegotiationForm()
  {
    return this.featureNegotiation.getData();
  }

  public File getFile()
  {
    return this.file;
  }

  public String getMimeType()
  {
    return this.mimeType;
  }

  public String getSessionID()
  {
    return this.id;
  }

  public void setFeatureNegotiationForm(DataForm paramDataForm)
  {
    this.featureNegotiation = new Feature(this, paramDataForm);
  }

  public void setFile(File paramFile)
  {
    this.file = paramFile;
  }

  public void setMimeType(String paramString)
  {
    this.mimeType = paramString;
  }

  public void setSesssionID(String paramString)
  {
    this.id = paramString;
  }

  public class Feature
  implements PacketExtension
  {
    private final DataForm data;

    public Feature(, DataForm paramDataForm)
    {
      this.data = paramDataForm;
    }

    public DataForm getData()
    {
      return this.data;
    }

    public String getElementName()
    {
      return "feature";
    }

    public String getNamespace()
    {
      return "http://jabber.org/protocol/feature-neg";
    }

    public String toXML()
    {
      StringBuilder localStringBuilder = new StringBuilder();
      localStringBuilder.append("<feature xmlns=\"http://jabber.org/protocol/feature-neg\">");
      localStringBuilder.append(this.data.toXML());
      localStringBuilder.append("</feature>");
      return localStringBuilder.toString();
    }
  }

  public static class File
  implements PacketExtension
  {
    private Date date;
    private String desc;
    private String hash;
    private boolean isRanged;
    private final String name;
    private final long size;

    public File(String paramString, long paramLong)
    {
      if (paramString == null)
        throw new NullPointerException("name cannot be null");
      this.name = paramString;
      this.size = paramLong;
    }

    public Date getDate()
    {
      return this.date;
    }

    public String getDesc()
    {
      return this.desc;
    }

    public String getElementName()
    {
      return "file";
    }

    public String getHash()
    {
      return this.hash;
    }

    public String getName()
    {
      return this.name;
    }

    public String getNamespace()
    {
      return "http://jabber.org/protocol/si/profile/file-transfer";
    }

    public long getSize()
    {
      return this.size;
    }

    public boolean isRanged()
    {
      return this.isRanged;
    }

    public void setDate(Date paramDate)
    {
      this.date = paramDate;
    }

    public void setDesc(String paramString)
    {
      this.desc = paramString;
    }

    public void setHash(String paramString)
    {
      this.hash = paramString;
    }

    public void setRanged(boolean paramBoolean)
    {
      this.isRanged = paramBoolean;
    }

    // ERROR //
    public String toXML()
    {
      // Byte code:
      //   0: new 67	java/lang/StringBuilder
      //   3: dup
      //   4: invokespecial 68	java/lang/StringBuilder:<init>	()V
      //   7: astore_1
      //   8: aload_1
      //   9: ldc 70
      //   11: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   14: aload_0
      //   15: invokevirtual 76	org/jivesoftware/smackx/packet/StreamInitiation$File:getElementName	()Ljava/lang/String;
      //   18: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   21: ldc 78
      //   23: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   26: aload_0
      //   27: invokevirtual 80	org/jivesoftware/smackx/packet/StreamInitiation$File:getNamespace	()Ljava/lang/String;
      //   30: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   33: ldc 82
      //   35: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   38: pop
      //   39: aload_0
      //   40: invokevirtual 84	org/jivesoftware/smackx/packet/StreamInitiation$File:getName	()Ljava/lang/String;
      //   43: ifnull +25 -> 68
      //   46: aload_1
      //   47: ldc 86
      //   49: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   52: aload_0
      //   53: invokevirtual 84	org/jivesoftware/smackx/packet/StreamInitiation$File:getName	()Ljava/lang/String;
      //   56: invokestatic 92	org/jivesoftware/smack/util/StringUtils:escapeForXML	(Ljava/lang/String;)Ljava/lang/String;
      //   59: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   62: ldc 82
      //   64: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   67: pop
      //   68: aload_0
      //   69: invokevirtual 94	org/jivesoftware/smackx/packet/StreamInitiation$File:getSize	()J
      //   72: lconst_0
      //   73: lcmp
      //   74: ifle +22 -> 96
      //   77: aload_1
      //   78: ldc 96
      //   80: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   83: aload_0
      //   84: invokevirtual 94	org/jivesoftware/smackx/packet/StreamInitiation$File:getSize	()J
      //   87: invokevirtual 99	java/lang/StringBuilder:append	(J)Ljava/lang/StringBuilder;
      //   90: ldc 82
      //   92: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   95: pop
      //   96: aload_0
      //   97: invokevirtual 101	org/jivesoftware/smackx/packet/StreamInitiation$File:getDate	()Ljava/util/Date;
      //   100: ifnull +39 -> 139
      //   103: getstatic 105	org/jivesoftware/smackx/packet/StreamInitiation:XEP_0082_UTC_FORMAT	Ljava/text/DateFormat;
      //   106: astore 9
      //   108: aload 9
      //   110: monitorenter
      //   111: aload_1
      //   112: ldc 107
      //   114: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   117: getstatic 105	org/jivesoftware/smackx/packet/StreamInitiation:XEP_0082_UTC_FORMAT	Ljava/text/DateFormat;
      //   120: aload_0
      //   121: getfield 39	org/jivesoftware/smackx/packet/StreamInitiation$File:date	Ljava/util/Date;
      //   124: invokevirtual 113	java/text/DateFormat:format	(Ljava/util/Date;)Ljava/lang/String;
      //   127: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   130: ldc 82
      //   132: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   135: pop
      //   136: aload 9
      //   138: monitorexit
      //   139: aload_0
      //   140: invokevirtual 115	org/jivesoftware/smackx/packet/StreamInitiation$File:getHash	()Ljava/lang/String;
      //   143: ifnull +22 -> 165
      //   146: aload_1
      //   147: ldc 117
      //   149: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   152: aload_0
      //   153: invokevirtual 115	org/jivesoftware/smackx/packet/StreamInitiation$File:getHash	()Ljava/lang/String;
      //   156: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   159: ldc 82
      //   161: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   164: pop
      //   165: aload_0
      //   166: getfield 43	org/jivesoftware/smackx/packet/StreamInitiation$File:desc	Ljava/lang/String;
      //   169: ifnull +13 -> 182
      //   172: aload_0
      //   173: getfield 43	org/jivesoftware/smackx/packet/StreamInitiation$File:desc	Ljava/lang/String;
      //   176: invokevirtual 123	java/lang/String:length	()I
      //   179: ifgt +10 -> 189
      //   182: aload_0
      //   183: getfield 58	org/jivesoftware/smackx/packet/StreamInitiation$File:isRanged	Z
      //   186: ifeq +95 -> 281
      //   189: aload_1
      //   190: ldc 125
      //   192: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   195: pop
      //   196: aload_0
      //   197: invokevirtual 127	org/jivesoftware/smackx/packet/StreamInitiation$File:getDesc	()Ljava/lang/String;
      //   200: ifnull +35 -> 235
      //   203: aload_0
      //   204: getfield 43	org/jivesoftware/smackx/packet/StreamInitiation$File:desc	Ljava/lang/String;
      //   207: invokevirtual 123	java/lang/String:length	()I
      //   210: ifle +25 -> 235
      //   213: aload_1
      //   214: ldc 129
      //   216: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   219: aload_0
      //   220: invokevirtual 127	org/jivesoftware/smackx/packet/StreamInitiation$File:getDesc	()Ljava/lang/String;
      //   223: invokestatic 92	org/jivesoftware/smack/util/StringUtils:escapeForXML	(Ljava/lang/String;)Ljava/lang/String;
      //   226: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   229: ldc 131
      //   231: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   234: pop
      //   235: aload_0
      //   236: invokevirtual 133	org/jivesoftware/smackx/packet/StreamInitiation$File:isRanged	()Z
      //   239: ifeq +10 -> 249
      //   242: aload_1
      //   243: ldc 135
      //   245: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   248: pop
      //   249: aload_1
      //   250: ldc 137
      //   252: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   255: aload_0
      //   256: invokevirtual 76	org/jivesoftware/smackx/packet/StreamInitiation$File:getElementName	()Ljava/lang/String;
      //   259: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   262: ldc 125
      //   264: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   267: pop
      //   268: aload_1
      //   269: invokevirtual 140	java/lang/StringBuilder:toString	()Ljava/lang/String;
      //   272: areturn
      //   273: astore 10
      //   275: aload 9
      //   277: monitorexit
      //   278: aload 10
      //   280: athrow
      //   281: aload_1
      //   282: ldc 142
      //   284: invokevirtual 74	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
      //   287: pop
      //   288: goto -20 -> 268
      //
      // Exception table:
      //   from	to	target	type
      //   111	139	273	finally
      //   275	278	273	finally
    }
  }
}